<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				var item = document.getElementsByName('itemc');
				var a = document.getElementById('a');
				var b = document.getElementById('b');
				var c = document.getElementById('c');
				var d = document.getElementById('d');
				var e = document.getElementById('e');
				var i;
				
				a.onclick = function(){
					for(i = 0; i < item.length; i++){
						item[i].checked = true;
					}
				}
				
				b.onclick = function(){
					for(i = 0; i < item.length; i++){
						item[i].checked = false;
					}
				}
				
				c.onclick = function(){
					for(i = 0; i < item.length; i++){
						item[i].checked = !item[i].checked;
					}
				}
				
				d.onclick = function(){
					for(i = 0; i < item.length; i++){
						if(item[i].checked){
							alert(item[i].value);
						}
					}
				}
				
				e.onclick = function(){
					for(i = 0; i < item.length; i++){
						item[i].checked = this.checked;
					}
				}
			}
		</script>
	</head>
	<body>
		<form action="js02.html" method="post">
					你爱好的运动是<input type="checkbox"  id="e" />全选/全不选<br>
					<input type="checkbox" name="itemc" id="" value="足球" />足球
					<input type="checkbox" name="itemc" id="" value="篮球" />篮球
					<input type="checkbox" name="itemc" id="" value="羽毛球" />羽毛球
					<input type="checkbox" name="itemc" id="" value="乒乓球" />乒乓球
					<br>
					<input type="button" name="" id="a" value="全选" />
					<input type="button" name="" id="b" value="全不选" />
					<input type="button" name="" id="c" value="反选" />
					<input type="button" name="" id="d" value="提交" />
				</form>
	</body>
</html>
